﻿// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
//
// 本项目主要遵循 MIT 许可证和 Apache 许可证（版本 2.0）进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
//
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动！任何基于本项目二次开发而产生的一切法律纠纷和责任，我们不承担任何责任！

using Admin.NET.Plugin.Easy.Wms.Enum;
using Admin.NET.Plugin.Easy.Wms.Enum.WareHouse;
using Admin.NET.Plugin.Easy.Wms.Util;
using Admin.NET.Plugin.Easy.Wms.Validator.WareHouse;
using Mapster;
using System.ComponentModel.DataAnnotations;

namespace Admin.NET.Plugin.Easy.Wms.Services.WareHouse.DTO;

/// <summary>
/// 添加仓库输入参数
/// </summary>
public class WareHouseAddInput
{
    /// <summary>
    /// 仓库编号
    /// </summary>
    [ExistSameWareHouseNum]
    public string? WareHouseNum { get; set; }

    /// <summary>
    /// 仓库名称
    /// </summary>
    [Required(ErrorMessage = "仓库名称不能为空")]
    public string WareHouseName { get; set; } = string.Empty;

    /// <summary>
    /// 仓库类型
    /// </summary>
    [Required(ErrorMessage = "仓库类型不能为空")]
    public Easy_Wms_WareHosueTypeEnum WareHouseType { get; set; }

    /// <summary>
    /// 仓库管理员
    /// </summary>
    public string? WareHouseAdmin { get; set; } = string.Empty;

    /// <summary>
    /// 仓库所在城市
    /// </summary>
    [MaxLength(20, ErrorMessage = "城市长度超出设定字符")]
    public string? WareHouseCity { get; set; } = string.Empty;

    /// <summary>
    /// 仓库详细地址
    /// </summary>
    [MaxLength(100, ErrorMessage = "详细地址长度超出设定字符")]
    public string? WareHouseAddress { get; set; } = string.Empty;

    /// <summary>
    /// 仓库备注
    /// </summary>
    public string? WareHouseRemark { get; set; } = string.Empty;
}

/// <summary>
/// 修改仓库输入参数
/// </summary>
public class WareHouseUpdateInput
{
    [Required(ErrorMessage = "Id不能为空")]
    public long Id { get; set; }

    /// <summary>
    /// 仓库编号
    /// </summary>
    public string? WareHouse_Num { get; set; }

    /// <summary>
    /// 仓库名称
    /// </summary>
    public string? WareHouse_Name { get; set; }

    /// <summary>
    /// 仓库类型
    /// </summary>
    public Easy_Wms_WareHosueTypeEnum? WareHouse_Type { get; set; }

    /// <summary>
    /// 仓库状态
    /// </summary>
    public Easy_Wms_GeneralStatusEnum? WareHouse_Status { get; set; }

    /// <summary>
    /// 仓库管理员
    /// </summary>
    public string? WareHouse_Admin { get; set; }

    /// <summary>
    /// 仓库所在城市
    /// </summary>
    public string? WareHouse_City { get; set; }

    /// <summary>
    /// 仓库详细地址
    /// </summary>
    public string? WareHouse_Address { get; set; }

    /// <summary>
    /// 仓库备注
    /// </summary>
    public string? WareHouse_Remark { get; set; }
}

/// <summary>
/// 删除仓库输入参数
/// </summary>
public class WareHouseDeleteInput : BaseIdInput
{

}

/// <summary>
/// 分页查询仓库信息
/// </summary>
public class WareHousePageInput : BasePage
{
    /// <summary>
    /// Id
    /// </summary>
    public long? Id { get; set; }

    /// <summary>
    /// 仓库编号
    /// </summary>
    public string? WareHouse_Num { get; set; }

    /// <summary>
    /// 仓库名称
    /// </summary>
    public string? WareHouse_Name { get; set; }

    /// <summary>
    /// 仓库类别
    /// </summary>
    public Easy_Wms_WareHosueTypeEnum? WareHouse_Type { get; set; }
}

/// <summary>
/// 对象映射器
/// </summary>
public class WareHouseInputMapper : IRegister
{
    public void Register(TypeAdapterConfig config)
    {
        config.ForType<Easy_Wms_WareHouseEntity, WareHouseAddInput>()
              .Map(dest => dest.WareHouseNum, src => src.WareHouse_Num)
              .Map(dest => dest.WareHouseName, src => src.WareHouse_Name)
              .Map(dest => dest.WareHouseType, src => src.WareHouse_Type)
              .Map(dest => dest.WareHouseAdmin, src => src.WareHouse_Admin)
              .Map(dest => dest.WareHouseCity, src => src.WareHouse_City)
              .Map(dest => dest.WareHouseAddress, src => src.WareHouse_Address)
              .Map(dest => dest.WareHouseRemark, src => src.WareHouse_Remark);
    }
}